// bzoj1895
// 题意：很直接，给定一个长度为n的数列，支持单点插入，单点删除，区间增加，
//       区间翻转，区间旋转，然后询问区间最小值。n和操作个数都<=100000。
//
// 题解：splay可以很方便支持这些操作。区间增加和区间翻转只需要打个lazy tag就行。
//       区间旋转的话其实本质是讲某个区间删除然后插入到另一个区间后面。
//       可作为splay模板。
//
// 统计：4.864s(bzoj)，coding time too much, too much tried
//
// run: time -p $exec < bfdiff.in
// flag: -g
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>

long long const maxn = 300100;
long long a[maxn];
long long const inf = 1 << 30;
int n, m;

namespace splay_tree
{
	struct node
	{
		node() { size = 0; min = value = inf; delta = 0; rev = false; }
		void set_child(node * c, long long is_right) { child[is_right] = c; c->parent = this; }
		bool is_right() { return this == parent->child[1]; }
		void add(long long d) { delta += d; min += d; value += d; }
		void reverse() { rev ^= true; }

		long long size, value, min, delta;
		bool rev;
		node * child[2], * parent;
	} * root, memory[maxn], * nil, * alloc = memory;

	node * node_alloc(long long v)
	{
		alloc->child[0] = alloc->child[1] = nil;
		alloc->size = 1;
		alloc->value = v;
		alloc->min = v;
		alloc->delta = 0;
		alloc->rev = false;
		return alloc++;
	}

	void relax(node * t)
	{
		if (t->delta) {
			for (long long i = 0; i < 2; i++)
				if (t->child[i] != nil) t->child[i]->add(t->delta);
			t->delta = 0;
		}
		if (t->rev) {
			std::swap(t->child[0], t->child[1]);
			for (long long i = 0; i < 2; i++)
				if (t->child[i] != nil) t->child[i]->reverse();
			t->rev = false;
		}
	}

	void update(node * t)
	{
		t->size = t->child[0]->size + t->child[1]->size + 1;
		t->min = std::min(t->value, std::min(t->child[0]->min, t->child[1]->min));
	}

	void rot(node * t)
	{
		node * p = t->parent;
		relax(p);
		relax(t);
		bool is_right = t->is_right();
		p->parent->set_child(t, p->is_right());
		p->set_child(t->child[!is_right], is_right);
		t->set_child(p, !is_right);
		update(p);
		if (p == root) root = t;
	}

	void splay(node * t, node * parent)
	{
		while (t->parent != parent) {
			if (t->parent->parent == parent)
				rot(t);
			else
				(t->is_right() == t->parent->is_right()) ?
					(rot(t->parent), rot(t)) :
						(rot(t), rot(t));
		}
		update(t);
	}

	void splay(node * t) { splay(t, nil); }

	node * build(int l, int r)
	{
		if (l >= r) return nil;
		int mid = (l + r) / 2;
		node * t = node_alloc(a[mid]);
		t->set_child(build(l, mid), 0);
		t->set_child(build(mid + 1, r), 1);
		update(t);
		return t;
	}

	void init(long long n)
	{
		nil = new node;
		root = build(0, n + 2); root->parent = nil;
	}

	node * select(long long k)
	{
		for (node * t = root; ; ) {
			relax(t);
			long long c = t->child[0]->size;
			if (k == c) return t;
			if (k > c)
				k -= c + 1, t = t->child[1];
			else
				t = t->child[0];
		}
	}

	// interval operations

	node * & get(int l, int r) // [l, r)
	{
		node * tl = select(l - 1);
		node * tr = select(r);
		splay(tl);
		splay(tr, tl);
		return tr->child[0];
	}

	void interval_add(int l, int r, int d)
	{
		node * & t = get(l, r + 1);
		t->add(d);
		splay(t);
	}

	void reverse(int l, int r)
	{
		node * & t = get(l, r + 1);
		t->reverse();
		splay(t);
	}

	long long query(int l, int r)
	{
		node * & t = get(l, r + 1);
		return t->min;
	}

	void insert(int x, int p)
	{
		node * t = select(p);
		node * tr = select(p + 1);
		splay(t);
		splay(tr, t);
		node * tmp = node_alloc(x);
		tmp->set_child(tr->child[0], 0);
		tr->set_child(tmp, 0);
		update(tr);
	}

	void remove(int p)
	{
		node * t = select(p - 1);
		node * tr = select(p + 1);
		splay(t);
		splay(tr, t);
		tr->child[0] = nil;
		update(tr);
		splay(tr);
	}

	void revolve(int l, int r, int shift)
	{
		int len = r - l + 1;
		shift = (shift % len + len) % len;
		if (!shift) return;

		// [l, r - shift], [r - shift + 1, r]
		node * tl = select(l - 1);
		node * tr = select(r - shift + 1);
		node * txr = select(r);
		node * txrr = select(r + 1);
		splay(tl);
		splay(tr, tl);
		relax(tr);
		node * tt = tr->child[0];
		tr->child[0] = nil;
		update(tr);
		splay(tr);

		splay(txr);
		splay(txrr, txr);
		relax(txrr);

		txrr->set_child(tt, 0);
		update(txrr);
		splay(txrr);
	}
};

int main()
{
	std::scanf("%d", &n);
	for (int i = 1; i <= n; i++) std::scanf("%lld", &a[i]);
	a[0] = a[n + 1] = a[n + 2] = inf;
	splay_tree::init(n);
	std::scanf("%d", &m);
	char command[10];
	for (long long i = 0; i < m; i++) {
		std::scanf("%s", command);
		if (!std::strcmp(command, "ADD")) {
			int l, r, d;
			std::scanf("%d %d %d", &l, &r, &d);
			splay_tree::interval_add(l, r, d);
			continue;
		}
		if (!std::strcmp(command, "REVERSE")) {
			int l, r;
			std::scanf("%d %d", &l, &r);
			splay_tree::reverse(l, r);
			continue;
		}
		if (!std::strcmp(command, "REVOLVE")) {
			int l, r, t;
			std::scanf("%d %d %d", &l, &r, &t);
			splay_tree::revolve(l, r, t);
			continue;
		}
		if (!std::strcmp(command, "INSERT")) {
			int x, p;
			std::scanf("%d %d", &p, &x);
			splay_tree::insert(x, p);
			continue;
		}
		if (!std::strcmp(command, "DELETE")) {
			int p;
			std::scanf("%d", &p);
			splay_tree::remove(p);
			continue;
		}
		if (!std::strcmp(command, "MIN")) {
			int l, r;
			std::scanf("%d %d", &l, &r);
			std::printf("%lld\n", splay_tree::query(l, r));
			continue;
		}
	}
}

